import { fliterPermission } from '@/utils/sys.js'

export const apis = {
  list: `/business/basis/getList?modelCode=MODEL_PLAN&authCode=FUNCTION_PLAN_LIST`,
  del: `business/plan/del?authCode=BTN_PLAN_DEL`,
  add: `business/plan/add?authCode=BTN_PLAN_ADD`,
  edit: `business/plan/edit?authCode=BTN_PLAN_EDIT`,
  detail: `business/basis/detail?modelCode=MODEL_PLAN&authCode=BTN_PLAN_DETAIL`,
  default: `business/plan/setDefault?modelCode=MODEL_PLAN&authCode=BTN_PLAN_DEFAULT`,

};
export const configs = {
  listUrl: apis.list,
  pageOn: true, // 开启分页
  searchOn: true, // 开启搜索
  operateOn: true, //开启操作区域
  treeOn: false, // 开启树形
};

export const searchs = [
  {
    type: "Input",
    column: "plan_name",
    label: "方案名称",
  },
  {
    type: "Select",
    column: "plan_type",
    label: "方案类型",
    dimCode: "DIM_PLAN_TYPE"
  }
];

export const pages = {
  pageSize: 20,
  orders: [
    {
      field: "id",
      sort: "desc",
    },
  ],
};
export const columns = [
  { type: "selection" },
  {
    label: "方案名称",
    column: "plan_name",
    sortable: "custom",
    display: "text",
  },
  {
    label: "方案类型",
    column: "plan_type",
    display: "state",
    format:'dim'
  },
  {
    label: "是否默认",
    column: "plan_default",
    display: "state",
    format:'dim'
  },
  {
    label: "提成比例",
    column: "plan_ratio",
    slot:"planRatio",
  },
  {
    label: "创建时间",
    column: "ctime",
    format: "datetime",
    display: "text",
    
  },
 
  {
    label: "操作",
    column: "operate",
    width: "220",
    fixed: "right",
  }
];

export const buttons = fliterPermission([
  {
    operate: "add",
    text: "新增",
    permission: 'BTN_PLAN_ADD',
 
  }
  
])
export const columnButtons = fliterPermission([
  {
    operate: "detail",
    text: "详情",
    permission: 'BTN_PLAN_DETAIL',
  },
  {
    operate: "edit",
    text: "编辑",
    permission: 'BTN_PLAN_EDIT',

  },
  {
    operate: "delete",
    text: "删除",
    permission: 'BTN_PLAN_DEL',
    type:'danger',
    hidden: ({ row })=> {
      if(['1'].includes(row.plan_default)){
        return true
      }
      return false
    },
  },
  {
    operate: "default",
    text: "设为默认",
    permission: 'BTN_PLAN_DEFAULT',
     hidden: ({ row })=> {
      if(['1'].includes(row.plan_default)){
        return true
      }
      return false
    },
    
  }
])
